import Vue from 'vue';
import VueRouter from 'vue-router';
import { transportRouter } from './transport'
import { importRouter } from './import'
import { exportRouter } from './export'
// import emas from '@csair/windvane-api-ehome'

Vue.use(VueRouter);

const routes = [
  // 登录页
  // {
  //   path: '/index',
  //   name: 'Index',
  //   params: { name: '登录' },
  //   component(resolve) {
  //     require(['../views/Index'],resolve)
  //   }
  // },
	{
		path: '/',
		name: 'HomeWork',
    meta: { keepAlive: true },
    component: () => import('../views/home/Home.vue')
  },
  /* 出口运输 */
  ...exportRouter,
  /* 进口运输 */
  ...importRouter,
  /* 国内运输 */
  ...transportRouter
];

const router = new VueRouter({
	routes
});

// 路由导航守卫
router.beforeEach((to, from, next) => {
  // 如果访问地址为 /login  将放行
  // if (to.path === '/index') return next()
  // 获取token
  // const tokenStr = window.localStorage.getItem('token')
  // if (!tokenStr) return next('/index')
  // if (!localStorage.getItem('token')) {
  //   emas
  //     .EmasInformation
  //     .getInformation()
  //     .then(result => {
  //       window.localStorage.setItem('token', result.token)
  //       alert(JSON.stringify(result))
  //     })
  // }
  next()
})
export default router;
